﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Dynamics.BusinessConnectorNet;
using System.Collections;


namespace PJ.Data.Partner
{
    public abstract class PartnerAXProvider<TDataInterface>
        : ItemAXProvider<TDataInterface>, IPartnerProvider<TDataInterface>
        where TDataInterface : class, IPartnerData
    {
        protected PartnerAXProvider(IPartnerCache<TDataInterface> cache)
            : base(cache)
        {

        }
        protected override void CopyFromContainer(IEnumerator enumerator, TDataInterface data)
        {
            base.CopyFromContainer(enumerator, data);
            if (enumerator.MoveNext())
            {
                data.Phone = ((string)enumerator.Current).Trim();
                if (enumerator.MoveNext())
                {
                    data.Address = ((string)enumerator.Current).Trim();
                    return;
                }
            }
            throw new ArgumentException("Container size error", "enumerator");
        }

    }
}
